//
//  WBNavController.m
//  sinaWeibo
//
//  Created by 李江波 on 2016/11/14.
//  Copyright © 2016年 lijiangbo. All rights reserved.
//

#import "WBNavController.h"
#import "WBBasicController.h"

@interface WBNavController ()

@end

@implementation WBNavController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{

    CGFloat count = self.childViewControllers.count;
    
    if (count > 0) {
        
        viewController.hidesBottomBarWhenPushed = true;
        
        if ([viewController isKindOfClass:[WBBasicController class]]) {
            
            WBBasicController *vc = (WBBasicController *)viewController;
            vc.navItem.leftBarButtonItem = [UIBarButtonItem backItemWithimage:[UIImage imageNamed:@"navigationbar_back_withtext"] highImage:[UIImage imageNamed:@"navigationbar_back_withtext_highlighted"] target:self action:@selector(pop) title:@"返回"];
        }else{
            //没有继承根控制器的话。要重新显示导航栏
            self.navigationBar.hidden = NO;
            viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem backItemWithimage:[UIImage imageNamed:@"navigationbar_back_withtext"] highImage:[UIImage imageNamed:@"navigationbar_back_withtext_highlighted"] target:self action:@selector(pop) title:@"返回"];
        }
        
    }
    
    [super pushViewController:viewController animated:YES];
}

-(void)pop{
    //没有继承根控制器的话，要隐藏导航栏
    self.navigationBar.hidden = YES;
    
    [self popViewControllerAnimated:YES];
}

@end



